﻿<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
    <script src="~/js/frame.js"></script>
</head>
<body>
    <div class="framecontainer">
        <div class="cloud-panel">
            <div class="cloud-panel-header ">
                <div class="cloud-panel-title">首页元件管理</div>
            </div>
            <div class="cloud-panel-body">
                <div class="listcontainer">
                    <div class="searchop">
                        <div class="btnop">
                            <button class="btn btn-op" type="button" onclick="SaveElementSetting()"><span class="btntext">保存设置</span></button>
                        </div>
                        <div class="btnop">
                            <input id="ElementName" type="text" class="form-control searchinput" placeholder="请输入元件名称">
                            <button class="btn" type="button" onclick="BindGrid()"><i class="icon icon-search"></i><span class="searchtext">查询</span></button>
                        </div>
                    </div>
                    <div class="tableop">
                        <table class="GridStyle" id="CloudGrid" keyid="ElementGuid" url="oplist" relationpageid="cloudpagination" otherparm="SearchParm" afterbind="AfterBindData">
                            <tr class="HeaderStyle">
                                <th scope="col" style="width: 10px;" field="check" rowalign="center"></th>
                                <th scope="col" style="width: 10px;" field="index" rowalign="center">序</th>
                                <th scope="col" field="ElementName" rowalign="left">元件名称</th>
                                <th scope="col" field="function" functionname="GetIsPublic" style="width: 100px;" rowalign="center">完全公开</th>
                                <th scope="col" style="width: 50px;" field="SortNum" rowalign="center">排序</th>
                                <th scope="col" style="width: 50px;" field="EditButton" functionname="GridEdit" rowalign="center">设置</th>
                            </tr>
                        </table>
                    </div>
                    <div class="bottomop">
                        <div class="pageop">
                            <ul class="pagination" id="cloudpagination"></ul>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
    <script>
        $(function () {
            BindGrid();
        })
        function BindGrid() {
            BindCloudGrid($("#CloudGrid"))
        }

        function SearchParm() {
            return {
                "ElementName": $("#ElementName").val(),
            };
        }
        function AfterBindData() {

        }
        function GridEdit(RowData) {
            OpenTopDialog("编辑权限", "frame/extend/elementright/edit?elementguid=" + RowData.ElementGuid, 600, 800, BindGrid)
        }
        function GetIsPublic(RowData) {
            if (RowData.IsPublic == 100) {
                return "<input type='checkbox' class='IsPublicCheckBox' checked ElementGuid='" + RowData.ElementGuid + "' >"
            } else {
                return "<input type='checkbox' class='IsPublicCheckBox'  ElementGuid='" + RowData.ElementGuid + "' >"
            }
        }

        function SaveElementSetting() {
            var Result = [];
            $(".IsPublicCheckBox").each(function () {
                if ($(this).prop('checked')) {
                    Result.push({ "ElementGuid": $(this).attr("ElementGuid"), "IsPublic": 100 });
                } else {
                    Result.push({ "ElementGuid": $(this).attr("ElementGuid"), "IsPublic": 200 });
                }
            })
            CloudPost({ "ElementRightStr": JSON.stringify(Result) }, getRootPath() + "frame/extend/element/batchUpdateElementPublicSetting", function (res) {
                if (res.code == 0) {
                    OpenSuccess("保存成功", BindGrid)
                }
            })
        }
    </script>
</body>
</html>
